//
// RS Game Framework
// Copyright © 2009 Jedd Haberstro
// jhaberstro@gmail.com
// 
// $Id:
//

#ifndef RS_SCOPEDLOCK_HPP
#define RS_SCOPEDLOCK_HPP

namespace rs
{
	template< typename TLockable >
	class ScopedLock
	{
	public:
		
		typedef TLockable LockableType;
		
	public:
		
		ScopedLock(LockableType& lock);
		
		~ScopedLock();
		
	private:
		
		LockableType& lock_;
	};
	
	
	inline ScopedLock::ScopedLock(LockableType& lock)
	: lock_(lock) {
		lock_.Lock();
	}
	
	inline ScopedLock::~ScopedLock() {
		lock_.Unlock();
	}
}

#endif // RS_SCOPEDLOCK_HPP
